
<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
   :width="conf.width"
    draggable
     top="10vh" 
    :close-on-click-modal="false"
  >
  <el-form :model="form"  ref="form" :rules="rules_aabcg">
    <el-row>
    <el-col :span="12">
    <!-- {"index":34,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","v","DN","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="32" 
      :rows="0"  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":37,"raw":"status","name":"status","cname":"Status","type":{"raw":"tinyint","name":"tinyint","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","q","u","l","sl(status)","DS","color","tp(switch,l)","tp(radio)"],"desc":{"raw":"状态","name":"状态"}} -->
    <el-form-item prop="status" label="状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.status"   >
        <el-radio-button v-for="item in statusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":40,"raw":"memo","name":"memo","cname":"Memo","type":{"raw":"varchar2(64)","name":"varchar2","len":64,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","u","q","v","#like"],"desc":{"raw":"备注","name":"备注"}} -->
    <!--备注 输入控件 -->
    <el-form-item prop="memo" label="备注" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.memo"  maxlength="64" 
      :rows="0"  type="textarea" show-word-limit  placeholder="请输入备注"  />
      </el-form-item>
    </el-col>
    </el-row>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        title:"添加平台",
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
rules_aabcg:{
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    status:[{required:false,message:"请输入状态",trigger: 'blur'}],
    memo:[{required:false,message:"请输入备注",trigger: 'blur'}],
  },
    form:{
        name:"",
        status:"",
        memo:"",
    },
    statusList:[],
    }
  },
  methods: {
    show(fm = {}) {
      this.title = fm.$title || this.title
      this.conf.visible = true;
      this.loadEnums_aabcg()
      let local = {}
      let cache = Object.assign(local,fm)
      this.form = Object.assign(cache,this.$route.params)
    },
    save(){
      this.$refs.form.validate((v=>{
          if(v) this.onSave()
      }))
    },
    onSave(){
        let that = this
        let postForm = Object.assign({},this.form)
        postForm.lob_id = this.$theia.user.get("lob_id")
        //保存数据
        this.$theia.http.post("/ws/olb/system",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '业务系统保存成功',duration:5000})
            that.hide()
            that.$theia.enum.clear()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg= `业务系统保存失败(${code})`
            msg = code == 909? msg+"数据重复，请修改后重试":msg
            that.$notify.error({title: '失败',message:msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
    onUploadSuccess(response){
    },
    loadEnums_aabcg(){
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

},
}
</script>

<style scoped>
.avatar-uploader .avatar {
  width: 80px;
  height: 80px;
  display: block;
}
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>